/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * JPanelTricks.java
 *
 * Created on Dec 4, 2011, 11:55:02 AM
 */
package recitation;

import target.*;

/**
 *
 * @author buer
 */
public class JPanelTricks extends javax.swing.JPanel {

    /** Creates new form JPanelTricks */
    public JPanelTricks(Word oneWord) {
        initComponents();
        this.oneWord = oneWord;
        setShowText(this.oneWord);

    }

    /**
     * 显示单词记忆小窍门的方法，并设置文本区域的读写性与单词一致
     * @param oneWord 
     */
    public void setShowText(Word oneWord) {
        wordTricksText.append(oneWord.tricks);
        wordTricksText.setEditable(false);
    }

    /**
     * 获得文本区域内容
     * @return tricks String
     */
    public String getShowText() {
        return wordTricksText.getText();
    }

    public void updateContent(Word word) {
        wordTricksText.setText(word.tricks);
    }

    /**
     * 设置文本框的可编辑行
     * @param flag 
     */
    public void setEditable(boolean flag) {
        wordTricksText.setEditable(flag);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jScrollPane1 = new javax.swing.JScrollPane();
        wordTricksText = new javax.swing.JTextArea();

        setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 0, 0), 1, true));
        setPreferredSize(new java.awt.Dimension(378, 50));

        wordTricksText.setColumns(20);
        wordTricksText.setRows(5);
        jScrollPane1.setViewportView(wordTricksText);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 390, javax.swing.GroupLayout.PREFERRED_SIZE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 48, javax.swing.GroupLayout.PREFERRED_SIZE)
        );
    }// </editor-fold>//GEN-END:initComponents
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTextArea wordTricksText;
    // End of variables declaration//GEN-END:variables
    private Word oneWord;
}
